package testCase;

import junit.framework.TestCase;
import main.*;
import java.io.*;

public class testIO extends TestCase{
	private IO io;

	/**
	* Sets up the test fixture.
	*
	* Called before every test case method.
	*/
	public void setUp() { 
		io = new IO();
	}

	/**
	* Tears down the test fixture.
	*
	* Called after every test case method.
	*/
	public void tearDown() {}
		
	
	
	
	/**
	 * Test whenever the output contains the message
	 * 
	 * Input: msg
	 * Expected result: Normal
	 */
	public void testShowMsg(){
		String actualStr = "This is the test msg.";
		
		//create print stream to hold the output
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		PrintStream printStream = new PrintStream(baos);
		
		//create specific IO object
		IO ioInstance = new IO(System.in, printStream);
		ioInstance.showMsg(actualStr);
		
		assertTrue(baos.toString().contains(actualStr));
	}
	
	
	
	
	
	/**
	 * Test the default constructor
	 * 
	 * Input : none
	 * Expected result: Normal 
	 */
	public void testDefaultConstructor() {}
	
	
	/**
	 * Test the type conversion constructor 
	 * - IO(InputStream inputStream, PrintStream printStream)
	 * 
	 * Input : inputStream, printStream
	 * Expected result: Normal 
	 */
	public void testTCConstructor() {
		new IO(System.in, System.out);
		
	}
	
	
	 /** Test the method startGame()
	 * 
	 * Input : none
	 * Expected result: Normal 
	 *
	public void testStartGame() {
		io.startGame();
	}
	
	

	 /** Test the method showField()
	 * 
	 * Input : array with 10x10, 10 ,10
	 * Expected result: Normal 
	 */
	public void testShowField10x10() {
		char c[][] = new char[10][10];
		io.showField(c,10,10);
	}
	
	
	 /** Test the method showField()
	 * 
	 * Input : array with 20x1, 20 ,1
	 * Expected result: Normal 
	 */
	public void testShowField20x1() {
		char c[][] = new char[1][20];
		io.showField(c,20,1);
	}
	
	 /** Test the method showField()
	 * 
	 * Input : array with 1x20, 1 ,20
	 * Expected result: Normal 
	 */
	public void testShowField1x20() {
		char c[][] = new char[20][1];
		io.showField(c,1,20);
	}
	
	 /** Test the method showField()
	 * 
	 * Input : array with 1x1, 1 ,1
	 * Expected result: Normal 
	 */
	public void testShowField1x1() {
		char c[][] = new char[1][1];
		io.showField(c,1,1);
	}
	
	 /** Test the method showField()
	 * 
	 * Input : array with 0x1, 0 ,1
	 * Expected result: Normal 
	 */
	public void testShowField0x1() {
		char c[][] = new char[1][0];
		io.showField(c,0,1);
	}
	
	 /** Test the method showField()
	 * 
	 * Input : array with 1x1, -1 ,1
	 * Expected result: Fail 
	 */
	public void testShowFieldFailv1() {
		char c[][] = new char[1][1];
		io.showField(c,-1,1);
		fail();
	}
	
	
	 /** Test the method showField()
	 * 
	 * Input : array with 1x1, 1 ,-1
	 * Expected result: Fail 
	 */
	public void testShowFieldFailv2() {
		char c[][] = new char[1][1];
		io.showField(c,1,-1);
		fail();
	}	
	
	
	
	
	
	 /** Test the method showMsg()
	 * 
	 * Input : ABCDE
	 * Expected result: Normal
	 */
	public void testShowMsgABCDE() {
		io.showMsg("ABCDE");
	}


	 /** Test the method showMsg()
	 * 
	 * Input : ABCDE
	 * Expected result: Normal
	 */
	public void testShowMsgNull() {
		io.showMsg(null);
	}

	

	
	
	
	
	
	
	
	
}
